package com.lijian.reptile.model;
import com.lijian.reptile.ui.Perview;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.*;

import com.lijian.reptile.ui.MyFrame;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import java.io.IOException;

/**
 * ClassName: Read
 * Description:
 * date: 2021/11/24 0024 下午 3:17
 *
 * @author LiJian
 * @since JDK 1.8
 */
public class Read{

     Document document;

    public void send(String url){

        //定义文件类 使用InputStream流，OutputStream 传输到本地
       // File file1 = new File("D:\\Desktop\\笔记\\A.txt");

       // FileWriter writer;
        try {
                    //得到文档       获得连接，打开连接
                    document =  Jsoup.connect(url).get();

                    //Elements elements = document.select("img "); //获得海报路径
                    Elements elements = document.select(".zjbox a");
                    //Elements elements = document.select("#content");

                    //获得标题
                    System.out.println(document.title());
                    //单个元素的遍历
                    for (Element e:elements) {
                        //System.out.println(e.text());
                        //获取元素中的href
                        //System.out.println(e.text());
                        String  content = e.text();
                        Perview.jTA.append(content+"\n");
                        Document document1 = Jsoup.connect(url+e.attr("href")).get();
                         content = document1.select("#content").text();

                        Perview.jTA.append(content+"\r\n");
                    }



                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
}

